package com.example.mobiledatapackage.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务异常，自定义的非 bug 异常
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends RuntimeException{

    // 业务异常的类型，所有类型枚举在了 BusinessExceptionType 类中
    private BusinessExceptionType errorType;

    // 业务异常的用于展示在日志中的内部报错信息
    private String internalMsg;

    public BusinessException (BusinessExceptionType t, String internalMsg) {
        super(t.getExternalMsg());
        this.errorType = t;
        this.internalMsg = internalMsg;
    }

    /**
     * 不写入堆栈信息，提高性能
     */
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
